package com.chookss.home.rank;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.chookss.R;
import com.chookss.base.BaseViewHolderEx;
import com.chookss.home.entity.NavigationEntity;
import com.chookss.tools.Utils;
import com.chookss.view.RankDialog;

import java.util.ArrayList;

public class RankAdapter1 extends BaseQuickAdapter<RankEntity, BaseViewHolderEx> {
    private Context mContext;
    private int index = 0;
    private int num = 0;
    private int dayType = 0;//0是正常模式展示 1代表第8个要展示更多
    private ArrayList<NavigationEntity> data;

    public RankAdapter1(int layoutResId, Context context, @io.reactivex.annotations.Nullable ArrayList<RankEntity> data,int dayType) {
        super(layoutResId, data);
        this.mContext = context;
        this.dayType = dayType;
    }

    @Override
    protected void convert(BaseViewHolderEx helper, RankEntity entity) {
        LinearLayout llBg = helper.getView(R.id.llBg);
        TextView tv1 = helper.getView(R.id.tv1);
        TextView tv2 = helper.getView(R.id.tv2);
        TextView tv3 = helper.getView(R.id.tv3);
        TextView tv4 = helper.getView(R.id.tv4);
        if (helper.getItemPosition() % 2 == 0) {
            llBg.setBackgroundColor(Color.parseColor("#ffffff"));
        } else {
            llBg.setBackgroundColor(Color.parseColor("#f7f7f7"));
        }
        tv1.setText((helper.getItemPosition() + 1) + "");
        if (Utils.isNull(entity.getWeekNo())) {
            tv2.setText(entity.getCreateTime());
        } else {
            tv2.setText(entity.getYearNo() + "年第" + entity.getWeekNo() + "周");
        }
        tv3.setText(entity.getVisitNum());
        tv4.setText(entity.getEmpNum());
        helper.getItemView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new RankDialog(mContext, dayType,entity).show();
            }
        });
    }
}